package com.hundsun.yr.universal.p2p.bean;

import java.io.Serializable;
import java.math.BigDecimal;

import com.hundsun.yr.universal.library.utils.MathUtils;

/**
 * 信贷产品信息类
 * 
 * @author tonglj
 * 
 */
public class CreditLineBean implements Serializable {

	private static final long serialVersionUID = 1L;
	// {"availableAmount":790000.0000,"creditAmount":1000000.0000,"creditLevel":"BEST","creditScore":100,"creditType":"NORMAL","endDate":1460649599000,"frozenAmount":210000.0000,"startDate":1455552000000,"tenantId":"WWW","usedAmount":210000.0000,"userNo":"WWWUN0000000930","valid":false}
	/**
	 * 可用额度
	 */
	private BigDecimal availableAmount;
	/**
	 * 授信额度
	 */
	private BigDecimal creditAmount;
	/**
	 * 信用等级
	 */
	private String creditLevel;
	/**
	 * 信用评分
	 */
	private int creditScore;
//	/**
//	 * 授信类型
//	 */
//	private String creditType;
	/**
	 * 失效日期
	 */
	private long endDate;
	/**
	 * 冻结额度
	 */
	private BigDecimal frozenAmount;
	/**
	 * 生效日期
	 */
	private long startDate;
	/**
	 * 已用额度
	 */
	private BigDecimal usedAmount;
	/**
	 * 
	 */
	private boolean valid;


	/**
	 * BEST("1", "极好"),
    GOOD("2", "优秀"),
    NORMAL("3", "良好"),
    MEDIUM("4", "中等"),
    POOR("5", "较差");
	 * @return
	 */
	public String getCreditLevel() {
		int LIVEL = 6; 
		if("1".equals(creditLevel)){
			LIVEL = 1;
		}else if("2".equals(creditLevel)){
			LIVEL = 2;
		}else if("3".equals(creditLevel)){
			LIVEL = 3;
		}else if("4".equals(creditLevel)){
			LIVEL = 4;
		}else if("5".equals(creditLevel)){
			LIVEL = 5;
			
		}
		return "AAAAA".substring(LIVEL-1,5);
	}
//	
	

	public boolean isValid() {
		return valid;
	}

	public void setValid(boolean valid) {
		this.valid = valid;
	}

	public void setCreditLevel(String creditLevel) {
		this.creditLevel = creditLevel;
	}

	public int getCreditScore() {
		return creditScore;
	}

	public void setCreditScore(int creditScore) {
		this.creditScore = creditScore;
	}

//	public String getCreditType() {
//		return creditType;
//	}
//
//	public void setCreditType(String creditType) {
//		this.creditType = creditType;
//	}

	public long getEndDate() {
		return endDate;
	}

	public void setEndDate(long endDate) {
		this.endDate = endDate;
	}



	public long getStartDate() {
		return startDate;
	}

	public void setStartDate(long startDate) {
		this.startDate = startDate;
	}


	public BigDecimal getAvailableAmount() {
		
		return availableAmount;
	}


	public void setAvailableAmount(BigDecimal availableAmount) {
		if(availableAmount != null){
			availableAmount = new BigDecimal(0);
		}
		this.availableAmount = availableAmount;
	}


	public BigDecimal getCreditAmount() {
		
		return creditAmount;
	}


	public void setCreditAmount(BigDecimal creditAmount) {
		if(creditAmount != null){
			creditAmount = new BigDecimal(0);
		}
		this.creditAmount = creditAmount;
	}


	public BigDecimal getFrozenAmount() {
		
		return frozenAmount;
	}


	public void setFrozenAmount(BigDecimal frozenAmount) {
		if(frozenAmount != null){
			frozenAmount = new BigDecimal(0);
		}
		this.frozenAmount = frozenAmount;
	}


	public BigDecimal getUsedAmount() {
		
		return usedAmount;
	}


	public void setUsedAmount(BigDecimal usedAmount) {
		if(usedAmount != null){
			usedAmount = new BigDecimal(0);
		}
		this.usedAmount = usedAmount;
	}


	/**
	 * 获取可用额度所占比例
	 * @return
	 */
	public float getRatio(){
		return  MathUtils.string2float(MathUtils.division(availableAmount.toString(), creditAmount.toString()));//(availableAmount.divide(creditAmount).floatValue());
	}
}
